package com.hymjweb.demo.hymj.native_bill_manage.mappper;

import com.alibaba.fastjson.JSONObject;
import com.hymjweb.demo.framework.sys.SysConstant;
import com.hymjweb.demo.framework.util.DataTypeUtil;
import com.hymjweb.demo.hymj.master_bill_manage.load.mapper.BNativeBillLoadMapper;
import com.hymjweb.demo.hymj.native_bill_manage.bean.BNativeBillPojo;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
@Component
public interface BNativeBillMapper {

    class BNativeBillMapperProvider {

        /**
         * 插入分单
         *
         * @param pojo
         * @return
         */
        public String insert(BNativeBillPojo pojo) {
            String sql = new SQL() {{
                INSERT_INTO("b_native_bill");
                VALUES("id", "#{id}");
                VALUES("attribution_department_id", "#{attributionDepartmentId}");
                VALUES("transport_species_id", "#{transportSpeciesId}");
                VALUES("transport_way_id", "#{transportWayId}");
                VALUES("transport_scope_id", "#{transportScopeId}");
                VALUES("city_id", "#{cityId}");
                VALUES("dest_city_id", "#{destCityId}");

                VALUES("delivery_customer_id", "#{deliveryCustomerId}");
                VALUES("delivery_customer_name", "#{deliveryCustomerName}");
                VALUES("delivery_customer_phone", "#{deliveryCustomerPhone}");
                VALUES("delivery_customer_address", "#{deliveryCustomerAddress}");

                VALUES("delivery_customer_contact_id", "#{deliveryCustomerContactId}");
                VALUES("delivery_customer_contact_name", "#{deliveryCustomerContactName}");
                VALUES("delivery_customer_contact_phone", "#{deliveryCustomerContactPhone}");

                VALUES("receive_customer_name", "#{receiveCustomerName}");
                VALUES("receive_customer_phone", "#{receiveCustomerPhone}");
                VALUES("receive_customer_address", "#{receiveCustomerAddress}");

                VALUES("pick_up_point_id", "#{pickUpPointId}");
                VALUES("pick_up_point_name", "#{pickUpPointName}");
                VALUES("pick_up_point_phone", "#{pickUpPointPhone}");
                VALUES("pick_up_point_address", "#{pickUpPointAddress}");
                VALUES("pick_up_goods_way_id", "#{pickUpGoodsWayId}");

                VALUES("sign_choose_id", "#{signChooseId}");
                VALUES("delivery_customer_saleman_id", "#{deliveryCustomerSalemanId}");
                VALUES("airport_id", "#{airportId}");
                VALUES("flight_date", "#{flightDate}");
                VALUES("flight_no", "#{flightNo}");
                VALUES("flight_name", "#{flightName}");
                VALUES("airlines_id", "#{airlinesId}");
                VALUES("plan_take_off_time", "#{planTakeOffTime}");
                VALUES("goods_name", "#{goodsName}");
                VALUES("goods_type_id", "#{goodsTypeId}");
                VALUES("packing_way_id", "#{packingWayId}");

                VALUES("volume_information", "#{volumeInformation}");
                VALUES("total_number", "#{totalNumber}");
                VALUES("actual_weight", "#{actualWeight}");
                VALUES("chargeable_weight", "#{chargeableWeight}");
                VALUES("weight_rate", "#{weightRate}");
                VALUES("volume", "#{volume}");
                VALUES("volume_rate", "#{volumeRate}");
                VALUES("ticket_price", "#{ticketPrice}");
                VALUES("transport_cost", "#{transportCost}");

                VALUES("declared_value", "#{declaredValue}");
                VALUES("insurance_rate", "#{insuranceRate}");
                VALUES("insurance_fee", "#{insuranceFee}");
                VALUES("open_bill_delivery_charge", "#{openBillDeliveryCharge}");
                VALUES("agent_delivery_charge", "#{agentDeliveryCharge}");
                VALUES("delivery_charge_comment", "#{deliveryChargeComment}");
                VALUES("agent_delivery_charge_account_check_status_id", "#{agentDeliveryChargeAccountCheckStatusId}");

                VALUES("pickup_driver_fee", "#{pickupDriverFee}");
                VALUES("pickup_driver_name", "#{pickupDriverName}");


                VALUES("tax", "#{tax}");
                VALUES("fuel_surcharge", "#{fuelSurcharge}");
                VALUES("collection_money", "#{collectionMoney}");
                VALUES("other_charges", "#{otherCharges}");
                VALUES("other_charges_comment", "#{otherChargesComment}");
                VALUES("service_charge", "#{serviceCharge}");
                VALUES("actual_transport_cost", "#{actualTransportCost}");

                VALUES("business_cost_allocation_id", "#{businessCostAllocationId}");
                VALUES("business_cost_allocation_type_id", "#{businessCostAllocationTypeId}");
                VALUES("business_cost_comment", "#{businessCostComment}");

                VALUES("print_actual_weight", "#{printActualWeight}");
                VALUES("print_chargeable_weight", "#{printChargeableWeight}");
                VALUES("print_weight_rate", "#{printWeightRate}");
                VALUES("print_volume", "#{printVolume}");
                VALUES("print_volume_rate", "#{printVolumeRate}");

                VALUES("inner_operation_charge", "#{innerOperationCharge}");
                VALUES("delivery_customer_payment_method_id", "#{deliveryCustomerPaymentMethodId}");
                VALUES("delivery_customer_payment_amount", "#{deliveryCustomerPaymentAmount}");
                VALUES("receive_customer_payment_method_id", "#{receiveCustomerPaymentMethodId}");
                VALUES("receive_customer_payment_amount", "#{receiveCustomerPaymentAmount}");

                VALUES("total_amount", "#{totalAmount}");
                VALUES("actual_amount", "#{actualAmount}");

                VALUES("cashier_id", "#{cashierId}");
                VALUES("open_bill_user_id", "#{openBillUserId}");
                VALUES("open_bill_date", "#{openBillDate}");
                VALUES("open_bill_department_id", "#{openBillDepartmentId}");
                VALUES("roll_call_department_id", "#{rollCallDepartmentId}");
                VALUES("comment", "#{comment}");

                VALUES("bill_load_status_id", "#{billLoadStatusId}");
                VALUES("bill_load_master_bill_ids", "#{billLoadMasterBillIds}");
                VALUES("business_cost_status_id", "#{businessCostStatusId}");
                VALUES("agent_delivery_charge_status_id", "#{agentDeliveryChargeStatusId}");
                VALUES("arrears_status_id", "#{arrearsStatusId}");
                VALUES("share_cost", "#{shareCost}");
                VALUES("share_cost_comment", "#{shareCostComment}");
                VALUES("operating_cost", "#{operatingCost}");
                VALUES("gross_profit", "#{grossProfit}");

                VALUES("drop_amount", "#{dropAmount}");
                VALUES("settlement_amount", "#{settlementAmount}");
                VALUES("drop_status_id", "#{dropStatusId}");
                VALUES("settlement_status_id", "#{settlementStatusId}");

                VALUES("cancel_status_id", "#{cancelStatusId}");
                VALUES("account_check_status_id", "#{accountCheckStatusId}");

                VALUES("refund_number", "#{refundNumber}");
                VALUES("refund_actual_weight", "#{refundActualWeight}");
                VALUES("refund_chargeable_weight", "#{refundChargeableWeight}");
                VALUES("refund_volume", "#{refundVolume}");

                VALUES("create_time", "#{createTime}");
                VALUES("create_user_id", "#{createUserId}");
                VALUES("update_time", "#{updateTime}");
                VALUES("update_user_id", "#{updateUserId}");
            }}.toString();
            return sql;
        }

        /**
         * 根据分单号更新该分单的配载状态
         *
         * @param billId
         * @param loadStatusId
         * @return
         */
        public String updateLoadStatus(String billId, long loadStatusId) {
            String sql = new SQL() {{
                UPDATE("b_native_bill t");
                SET("t.bill_load_status_id = " + loadStatusId);
                WHERE("t.id = " + DataTypeUtil.quoteStr(billId));
            }}.toString();
            return sql;
        }

        public String updateStatusId(String statusFieldName, Long statusId, String billIds, Date updateTime, String updateUserId) {
            String sql = new SQL() {{
                UPDATE("b_native_bill t");
                SET("t." + statusFieldName + " = " + statusId);
                SET("t.update_time = #{updateTime}");
                SET("t.update_user_id = #{updateUserId}");
                WHERE("t.id in ( " + billIds + ")");
            }}.toString();
            return sql;
        }

        /**
         * 更新分单
         *
         * @param pojo
         * @return
         */
        public String update(BNativeBillPojo pojo) {
            String sql = new SQL() {{
                UPDATE("b_native_bill t");
                SET("t.attribution_department_id = #{attributionDepartmentId}");
                SET("t.transport_species_id = #{transportSpeciesId}");
                SET("t.transport_way_id = #{transportWayId}");
                SET("t.transport_scope_id = #{transportScopeId}");
                SET("t.city_id = #{cityId}");
                SET("t.dest_city_id = #{destCityId}");

                SET("t.delivery_customer_id = #{deliveryCustomerId}");
                SET("t.delivery_customer_name = #{deliveryCustomerName}");
                SET("t.delivery_customer_phone = #{deliveryCustomerPhone}");
                SET("t.delivery_customer_address = #{deliveryCustomerAddress}");

                SET("t.delivery_customer_contact_id = #{deliveryCustomerContactId}");
                SET("t.delivery_customer_contact_name = #{deliveryCustomerContactName}");
                SET("t.delivery_customer_contact_phone = #{deliveryCustomerContactPhone}");

                SET("t.receive_customer_name = #{receiveCustomerName}");
                SET("t.receive_customer_phone = #{receiveCustomerPhone}");
                SET("t.receive_customer_address = #{receiveCustomerAddress}");

                SET("t.pick_up_point_id = #{pickUpPointId}");
                SET("t.pick_up_point_name = #{pickUpPointName}");
                SET("t.pick_up_point_phone = #{pickUpPointPhone}");
                SET("t.pick_up_point_address = #{pickUpPointAddress}");
                SET("t.pick_up_goods_way_id = #{pickUpGoodsWayId}");

                SET("t.sign_choose_id = #{signChooseId}");
                SET("t.delivery_customer_saleman_id = #{deliveryCustomerSalemanId}");
                SET("t.airport_id = #{airportId}");
                SET("t.flight_date = #{flightDate}");
                SET("t.flight_no = #{flightNo}");
                SET("t.flight_name = #{flightName}");
                SET("t.airlines_id = #{airlinesId}");
                SET("t.plan_take_off_time = #{planTakeOffTime}");
                SET("t.goods_name = #{goodsName}");
                SET("t.goods_type_id = #{goodsTypeId}");
                SET("t.packing_way_id = #{packingWayId}");

                SET("t.volume_information = #{volumeInformation}");
                SET("t.total_number = #{totalNumber}");
                SET("t.actual_weight = #{actualWeight}");
                SET("t.chargeable_weight = #{chargeableWeight}");
                SET("t.weight_rate = #{weightRate}");
                SET("t.volume = #{volume}");
                SET("t.volume_rate = #{volumeRate}");
                SET("t.ticket_price = #{ticketPrice}");
                SET("t.transport_cost = #{transportCost}");

                SET("t.declared_value = #{declaredValue}");
                SET("t.insurance_rate = #{insuranceRate}");
                SET("t.insurance_fee = #{insuranceFee}");
                SET("t.open_bill_delivery_charge = #{openBillDeliveryCharge}");
                SET("t.agent_delivery_charge = #{agentDeliveryCharge}");
                SET("t.delivery_charge_comment = #{deliveryChargeComment}");

                SET("t.agent_delivery_charge_account_check_status_id = #{agentDeliveryChargeAccountCheckStatusId}");

                SET("t.pickup_driver_fee = #{pickupDriverFee}");
                SET("t.pickup_driver_name = #{pickupDriverName}");


                SET("t.tax = #{tax}");
                SET("t.fuel_surcharge = #{fuelSurcharge}");
                SET("t.collection_money = #{collectionMoney}");
                SET("t.other_charges = #{otherCharges}");
                SET("t.other_charges_comment = #{otherChargesComment}");
                SET("t.service_charge = #{serviceCharge}");
                SET("t.actual_transport_cost = #{actualTransportCost}");

                SET("t.business_cost_allocation_id = #{businessCostAllocationId}");
                SET("t.business_cost_allocation_type_id = #{businessCostAllocationTypeId}");
                SET("t.business_cost_comment = #{businessCostComment}");

                SET("t.print_actual_weight = #{printActualWeight}");
                SET("t.print_chargeable_weight = #{printChargeableWeight}");
                SET("t.print_weight_rate = #{printWeightRate}");
                SET("t.print_volume = #{printVolume}");
                SET("t.print_volume_rate = #{printVolumeRate}");

                SET("t.inner_operation_charge = #{innerOperationCharge}");
                SET("t.delivery_customer_payment_method_id = #{deliveryCustomerPaymentMethodId}");
                SET("t.delivery_customer_payment_amount = #{deliveryCustomerPaymentAmount}");
                SET("t.receive_customer_payment_method_id = #{receiveCustomerPaymentMethodId}");
                SET("t.receive_customer_payment_amount = #{receiveCustomerPaymentAmount}");

                SET("t.total_amount = #{totalAmount}");
                SET("t.actual_amount = #{actualAmount}");

                SET("t.cashier_id = #{cashierId}");
                SET("t.open_bill_user_id = #{openBillUserId}");
                SET("open_bill_date = #{openBillDate}");
                SET("t.open_bill_department_id = #{openBillDepartmentId}");
                SET("t.roll_call_department_id = #{rollCallDepartmentId}");
                SET("t.comment = #{comment}");

                SET("t.bill_load_status_id = #{billLoadStatusId}");
                SET("t.bill_load_master_bill_ids = #{billLoadMasterBillIds}");
                SET("t.business_cost_status_id = #{businessCostStatusId}");
                SET("t.agent_delivery_charge_status_id = #{agentDeliveryChargeStatusId}");
                SET("t.arrears_status_id = #{arrearsStatusId}");
                SET("t.share_cost = #{shareCost}");
                SET("t.share_cost_comment = #{shareCostComment}");
                SET("t.operating_cost = #{operatingCost}");
                SET("t.gross_profit = #{grossProfit}");

                SET("t.drop_amount = #{dropAmount}");
                SET("t.settlement_amount = #{settlementAmount}");
                SET("t.drop_status_id = #{dropStatusId}");
                SET("t.settlement_status_id = #{settlementStatusId}");

                SET("t.cancel_status_id = #{cancelStatusId}");
                SET("t.account_check_status_id = #{accountCheckStatusId}");

                SET("t.refund_number = #{refundNumber}");
                SET("t.refund_actual_weight = #{refundActualWeight}");
                SET("t.refund_chargeable_weight = #{refundChargeableWeight}");
                SET("t.refund_volume = #{refundVolume}");

                SET("t.update_time = #{updateTime}");
                SET("t.update_user_id = #{updateUserId}");


                WHERE("t.id = #{id}");
            }}.toString();
            return sql;
        }


        public String updateSaveNativeBill(BNativeBillPojo pojo) {
            String sql = new SQL() {{
                UPDATE("b_native_bill t");
                SET("t.attribution_department_id = #{attributionDepartmentId}");
                SET("t.transport_species_id = #{transportSpeciesId}");
                SET("t.transport_way_id = #{transportWayId}");
                SET("t.transport_scope_id = #{transportScopeId}");
                SET("t.city_id = #{cityId}");
                SET("t.dest_city_id = #{destCityId}");

                SET("t.delivery_customer_id = #{deliveryCustomerId}");
                SET("t.delivery_customer_name = #{deliveryCustomerName}");
                SET("t.delivery_customer_phone = #{deliveryCustomerPhone}");
                SET("t.delivery_customer_address = #{deliveryCustomerAddress}");

                SET("t.delivery_customer_contact_id = #{deliveryCustomerContactId}");
                SET("t.delivery_customer_contact_name = #{deliveryCustomerContactName}");
                SET("t.delivery_customer_contact_phone = #{deliveryCustomerContactPhone}");

                SET("t.receive_customer_name = #{receiveCustomerName}");
                SET("t.receive_customer_phone = #{receiveCustomerPhone}");
                SET("t.receive_customer_address = #{receiveCustomerAddress}");

                SET("t.pick_up_point_id = #{pickUpPointId}");
                SET("t.pick_up_point_name = #{pickUpPointName}");
                SET("t.pick_up_point_phone = #{pickUpPointPhone}");
                SET("t.pick_up_point_address = #{pickUpPointAddress}");
                SET("t.pick_up_goods_way_id = #{pickUpGoodsWayId}");

                SET("t.sign_choose_id = #{signChooseId}");
                SET("t.delivery_customer_saleman_id = #{deliveryCustomerSalemanId}");
                SET("t.airport_id = #{airportId}");
                SET("t.flight_date = #{flightDate}");
                SET("t.flight_no = #{flightNo}");
                SET("t.flight_name = #{flightName}");
                SET("t.airlines_id = #{airlinesId}");
                SET("t.plan_take_off_time = #{planTakeOffTime}");
                SET("t.goods_name = #{goodsName}");
                SET("t.goods_type_id = #{goodsTypeId}");
                SET("t.packing_way_id = #{packingWayId}");

                // SET("t.volume_information = #{volumeInformation}");
                // SET("t.total_number = #{totalNumber}");
                // SET("t.actual_weight = #{actualWeight}");
                // SET("t.chargeable_weight = #{chargeableWeight}");
                // SET("t.volume = #{volume}");

//                SET("t.weight_rate = #{weightRate}");
//                SET("t.volume_rate = #{volumeRate}");
//                SET("t.ticket_price = #{ticketPrice}");
//                SET("t.transport_cost = #{transportCost}");
//
//                SET("t.declared_value = #{declaredValue}");
//                SET("t.insurance_rate = #{insuranceRate}");
//                SET("t.insurance_fee = #{insuranceFee}");
//                SET("t.open_bill_delivery_charge = #{openBillDeliveryCharge}");
//                SET("t.agent_delivery_charge = #{agentDeliveryCharge}");
                SET("t.delivery_charge_comment = #{deliveryChargeComment}");

//                SET("t.pickup_driver_fee = #{pickupDriverFee}");
                SET("t.pickup_driver_name = #{pickupDriverName}");

//                SET("t.tax = #{tax}");
//                SET("t.fuel_surcharge = #{fuelSurcharge}");
//                SET("t.collection_money = #{collectionMoney}");
//                SET("t.other_charges = #{otherCharges}");
                SET("t.other_charges_comment = #{otherChargesComment}");
                //SET("t.service_charge = #{serviceCharge}");
                //SET("t.actual_transport_cost = #{actualTransportCost}");

                SET("t.business_cost_allocation_id = #{businessCostAllocationId}");
                SET("t.business_cost_allocation_type_id = #{businessCostAllocationTypeId}");
                SET("t.business_cost_comment = #{businessCostComment}");

                SET("t.print_actual_weight = #{printActualWeight}");
                SET("t.print_chargeable_weight = #{printChargeableWeight}");
                SET("t.print_weight_rate = #{printWeightRate}");
                SET("t.print_volume = #{printVolume}");
                SET("t.print_volume_rate = #{printVolumeRate}");

                //SET("t.inner_operation_charge = #{innerOperationCharge}");
                SET("t.delivery_customer_payment_method_id = #{deliveryCustomerPaymentMethodId}");
                //SET("t.delivery_customer_payment_amount = #{deliveryCustomerPaymentAmount}");
                SET("t.receive_customer_payment_method_id = #{receiveCustomerPaymentMethodId}");
                //SET("t.receive_customer_payment_amount = #{receiveCustomerPaymentAmount}");

//                SET("t.total_amount = #{totalAmount}");
//                SET("t.actual_amount = #{actualAmount}");

                SET("t.cashier_id = #{cashierId}");
                SET("t.open_bill_user_id = #{openBillUserId}");
                SET("open_bill_date = #{openBillDate}");
                SET("t.open_bill_department_id = #{openBillDepartmentId}");
                SET("t.roll_call_department_id = #{rollCallDepartmentId}");
                SET("t.comment = #{comment}");

//                SET("t.bill_load_status_id = #{billLoadStatusId}");
//                SET("t.bill_load_master_bill_ids = #{billLoadMasterBillIds}");
//                SET("t.business_cost_status_id = #{businessCostStatusId}");
//                SET("t.agent_delivery_charge_status_id = #{agentDeliveryChargeStatusId}");
//                SET("t.arrears_status_id = #{arrearsStatusId}");
//                SET("t.share_cost = #{shareCost}");
//                SET("t.share_cost_comment = #{shareCostComment}");
//                SET("t.operating_cost = #{operatingCost}");
//                SET("t.gross_profit = #{grossProfit}");

//                SET("t.drop_amount = #{dropAmount}");
//                SET("t.settlement_amount = #{settlementAmount}");
//                SET("t.drop_status_id = #{dropStatusId}");
//                SET("t.settlement_status_id = #{settlementStatusId}");
//
//                SET("t.cancel_status_id = #{cancelStatusId}");
//                SET("t.account_check_status_id = #{accountCheckStatusId}");

//                SET("t.refund_number = #{refundNumber}");
//                SET("t.refund_actual_weight = #{refundActualWeight}");
//                SET("t.refund_chargeable_weight = #{refundChargeableWeight}");
//                SET("t.refund_volume = #{refundVolume}");

                SET("t.update_time = #{updateTime}");
                SET("t.update_user_id = #{updateUserId}");

                WHERE("t.id = #{id}");
            }}.toString();
            return sql;
        }


        public String getBNativeBillPojoById(String id) {
            String sql = new SQL() {{
                SELECT("t.*");
                FROM("b_native_bill t");
                WHERE(" t.id = " + DataTypeUtil.quoteStr(id));
            }}.toString();

            return sql;
        }

        /**
         * 350,0,分单配载状态,分单配载状态,XT_DIC_BILL_LOAD_STATUS
         * 351,350,未配载,未配载,""
         * 352,350,部分配载,部分配载,""
         * 353,350,全部配载,全部配载,""
         * <p>
         * 410,0,作废状态,作废状态,XT_DIC_CANCEL_STATUS
         * 411,410,未作废,未作废,
         * 412,410,已作废,已作废,
         *
         * @param param
         * @return
         */
        public String getBNativeBillPojoByCnd(Map param) {
            String sql = new SQL() {{
                SELECT("t.*");
                FROM("b_native_bill t");
                WHERE("1=1 and  (t.bill_load_status_id is null or t.bill_load_status_id != 353) and (t.cancel_status_id is null or t.cancel_status_id != 412) ");
            }}.toString();

            /**
             * key
             * transportSpeciesId
             * destCityId
             * airportId
             * airlinesId
             * flightDate
             * flightNo
             * existBillIds
             */
            String key = DataTypeUtil.toStringObject(param.get("key"));
            Long transportSpeciesId = DataTypeUtil.toLongObject(param.get("transportSpeciesId"));
            String destCityId = DataTypeUtil.toStringObject(param.get("destCityId"));
            String airportId = DataTypeUtil.toStringObject(param.get("airportId"));
            String airlinesId = DataTypeUtil.toStringObject(param.get("airlinesId"));
            String flightDate = DataTypeUtil.toStringObject(param.get("flightDate"));
            String flightNo = DataTypeUtil.toStringObject(param.get("flightNo"));
            String existBillIds = DataTypeUtil.toStringObject(param.get("existBillIds"));

            if (key != null) {
                sql += " and t.id like " + DataTypeUtil.quoteAllLikeStr(key);
            }
            if (transportSpeciesId != null) {
                sql += " and t.transport_species_id =" + transportSpeciesId;
            }

            if (destCityId != null) {
                sql += " and t.dest_city_id =" + DataTypeUtil.quoteStr(destCityId);
            }
            if (airportId != null) {
                sql += " and t.airport_id =" + DataTypeUtil.quoteStr(airportId);
            }
            if (airlinesId != null) {
                sql += " and t.airlines_id =" + DataTypeUtil.quoteStr(airlinesId);
            }
            if (flightDate != null) {
                sql += " and date_format(t.flight_date,'%Y-%m-%d')  =" + DataTypeUtil.quoteStr(flightDate);
            }
            if (flightNo != null) {
                sql += " and t.flight_no = " + DataTypeUtil.quoteStr(flightNo);
            }

            String ids = "";
            if (existBillIds != null) {
                String[] existBillIdArray = existBillIds.split(",");
                if (existBillIdArray.length > 0) {
                    for (String billIdValue : existBillIdArray) {
                        ids += DataTypeUtil.quoteStr(billIdValue) + ",";
                    }
                }
            }
            if (ids.length() > 0) {
                ids = ids.substring(0, ids.length() - 1);
                sql += " and t.id not in (" + ids + ")";
            }

            return sql;
        }

        public String getBNativeBillPojoListByInId(String billIds) {
            String sql = new SQL() {{
                SELECT("t.* ");
                FROM("b_native_bill t");
                WHERE("t.id in (" + billIds + ")");
            }}.toString();
            return sql;
        }

        public String queryBNativeBillPojoListByMasterBillId(String masterBillId) {
            String sql = new SQL() {{
                SELECT("t.* ");
                FROM("b_native_bill t");
                WHERE("t.id in (select native_bill_id from b_native_bill_load t where t.master_bill_id = " + DataTypeUtil.quoteStr(masterBillId) + ")");
            }}.toString();
            return sql;
        }


        public String getDailyReportList(Map<String, Object> param) {
            String sql = findAll(param);
            String czyId = DataTypeUtil.toStringObject(param.get("czyId"));

            if (czyId != null) {
                sql += " and t.open_bill_user_id = " + DataTypeUtil.quoteStr(czyId);
            }
            return sql;
        }


        public String findAll(Map map) {
            String sql = new SQL() {{
                SELECT("t.* ");
                FROM("b_native_bill t where 1 = 1 ");
            }}.toString();

            // keyBillCode  keyAttributionDepartmentId  keyTransportSpeciesId  keyTransportWayId  keyDeliveryCustomerId  keyOpenBillStartDate  keyOpenBillEndDate

            /**
             * "keyBillCode" -> ""  String keyBillCode = DataTypeUtil.toNotNullString(map.get("keyBillCode"));
             * "keyOpenBillEndDate" -> ""  String keyOpenBillEndDate = DataTypeUtil.toNotNullString(map.get("keyOpenBillEndDate"));
             * "keyTransportWayId" -> ""  Long keyTransportWayId = DataTypeUtil.toLong(map.get("keyTransportWayId"), -1);
             * "keyTransportSpeciesId" -> "" Long keyTransportSpeciesId = DataTypeUtil.toLong(map.get("keyTransportSpeciesId"), -1);
             * "keyOpenBillStartDate" -> "" String keyOpenBillStartDate = DataTypeUtil.toNotNullString(map.get("keyOpenBillStartDate"));
             * "keyShareCostCommentLength" -> {Integer@11011} 10  Long keyShareCostCommentLength = DataTypeUtil.toLongObject(map.get("keyShareCostCommentLength"));
             * "keyDeliveryCustomerId" -> ""  String keyDeliveryCustomerId = DataTypeUtil.toNotNullString(map.get("keyDeliveryCustomerId"));
             * "keyAttributionDepartmentId" -> ""  String keyAttributionDepartmentId = DataTypeUtil.toStringObject(map.get("keyAttributionDepartmentId"));
             */

            if (map != null) {
                sql = queryCndCreate(map, sql);

            }

            return sql;
        }

        private String queryCndCreate(Map map, String sql) {
            String keyBillCode = DataTypeUtil.toNotNullString(map.get("keyBillCode"));
            String keyAttributionDepartmentId = DataTypeUtil.toStringObject(map.get("keyAttributionDepartmentId"));
            Long keyTransportSpeciesId = DataTypeUtil.toLong(map.get("keyTransportSpeciesId"), -1);
            Long keyTransportWayId = DataTypeUtil.toLong(map.get("keyTransportWayId"), -1);

            String keyGoodsName = DataTypeUtil.toStringObject(map.get("keyGoodsName"));
            String keyAirportId = DataTypeUtil.toStringObject(map.get("keyAirportId"));
            String keyDestCityId = DataTypeUtil.toStringObject(map.get("keyDestCityId"));
            String keyFlightName = DataTypeUtil.toStringObject(map.get("keyFlightName"));

            String keyDeliveryCustomerId = DataTypeUtil.toNotNullString(map.get("keyDeliveryCustomerId"));
            String keyReceiveCustomerName = DataTypeUtil.toNotNullString(map.get("keyReceiveCustomerName"));
            String keyPickUpPointId = DataTypeUtil.toNotNullString(map.get("keyPickUpPointId"));
            Long keyPickUpGoodsWayId = DataTypeUtil.toLong(map.get("keyPickUpGoodsWayId"), -1);
            Long keySignChooseId = DataTypeUtil.toLong(map.get("keySignChooseId"), -1);
            String keyOpenBillStartDate = DataTypeUtil.toNotNullString(map.get("keyOpenBillStartDate"));
            String keyOpenBillEndDate = DataTypeUtil.toNotNullString(map.get("keyOpenBillEndDate"));
            String keyCashierId = DataTypeUtil.toStringObject(map.get("keyCashierId"));
            Long keyBillLoadStatusId = DataTypeUtil.toLong(map.get("keyBillLoadStatusId"), -1);

            String keyOpenBillDepartmentId = DataTypeUtil.toStringObject(map.get("keyOpenBillDepartmentId"));
            Long keyAgentDeliveryChargeStatusId = DataTypeUtil.toLongObject(map.get("keyAgentDeliveryChargeStatusId"));
            Long keyAgentDeliveryChargeAccountCheckStatusId = DataTypeUtil.toLongObject(map.get("keyAgentDeliveryChargeAccountCheckStatusId"));


            Long keyBusinessCostStatusId = DataTypeUtil.toLongObject(map.get("keyBusinessCostStatusId"));

            Long keyDropStatusId = DataTypeUtil.toLongObject(map.get("keyDropStatusId"));
            Long keyAccountCheckStatusId = DataTypeUtil.toLongObject(map.get("keyAccountCheckStatusId"));
            Long keySettlementStatusId = DataTypeUtil.toLongObject(map.get("keySettlementStatusId"));
            Long keyCancelStatusId = DataTypeUtil.toLongObject(map.get("keyCancelStatusId"));

            String keyDeliveryCustomerContactId = DataTypeUtil.toStringObject(map.get("keyDeliveryCustomerContactId"));

            String keyExcludeBillCodeIds = DataTypeUtil.toStringObject(map.get("keyExcludeBillCodeIds"));

            Long keyShareCostCommentLength = DataTypeUtil.toLongObject(map.get("keyShareCostCommentLength"));

            Long keyDeliveryCustomerPaymentMethodId = DataTypeUtil.toLong(map.get("keyDeliveryCustomerPaymentMethodId"), -1);
            Long keyReceiveCustomerPaymentMethodId = DataTypeUtil.toLong(map.get("keyReceiveCustomerPaymentMethodId"), -1);

            String createOrUpdateUserId = DataTypeUtil.toStringObject(map.get("createOrUpdateUserId"));

            String czyId = DataTypeUtil.toStringObject(map.get("czyId"));
            String departmentId = DataTypeUtil.toStringObject(map.get("departmentId"));


            if (keyBillCode != null && !"".equals(keyBillCode)) {
                sql += " and t.id=" + DataTypeUtil.quoteStr(keyBillCode);
            }

            if (keyAttributionDepartmentId != null) {
                String[] keyAttributionDepartmentIdArray = keyAttributionDepartmentId.split(",");
                if(keyAttributionDepartmentIdArray.length > SysConstant.INT_ZERO){
                    String tempSql = " and t.attribution_department_id in (";
                    for(String attributionDepartmentId : keyAttributionDepartmentIdArray){
                        tempSql += DataTypeUtil.quoteStr(attributionDepartmentId) + ",";
                    }
                    tempSql = tempSql.substring(0,tempSql.length()-1) + ") ";
                    sql += tempSql;
                }


               // sql += " and t.attribution_department_id = " + DataTypeUtil.quoteStr(keyAttributionDepartmentId);
            }

            if (keyTransportSpeciesId != -1L) {
                sql += " and t.transport_species_id=" + keyTransportSpeciesId;
            }
            if (keyTransportWayId != -1L) {
                sql += " and t.transport_way_id=" + keyTransportWayId;
            }


            /**
             * String keyGoodsName = DataTypeUtil.toStringObject(map.get("keyGoodsName"));
             *                 String keyAirportId = DataTypeUtil.toStringObject(map.get("keyAirportId"));
             *                 String keyDestCityId = DataTypeUtil.toStringObject(map.get("keyDestCityId"));
             */

            if (keyGoodsName != null) {
                sql += " and t.goods_name like " + DataTypeUtil.quoteAllLikeStr(keyGoodsName);
            }

            if (keyAirportId != null) {
                sql += " and t.airport_id = " + DataTypeUtil.quoteStr(keyAirportId);
            }

            if (keyDestCityId != null) {
                sql += " and t.dest_city_id = " + DataTypeUtil.quoteStr(keyDestCityId);
            }

            if (keyFlightName != null) {
                sql += " and t.flight_name = " + DataTypeUtil.quoteStr(keyFlightName);
            }


            if (!"".equals(keyDeliveryCustomerId)) {
                sql += " and t.delivery_customer_id = " + DataTypeUtil.quoteStr(keyDeliveryCustomerId);
            }

            if (!"".equals(keyReceiveCustomerName)) {
                sql += " and t.receive_customer_name like " + DataTypeUtil.quoteAllLikeStr(keyReceiveCustomerName);
            }

            // keyPickUpPointId: "1000001,1000002,1000003,1000


            if (!"".equals(keyPickUpPointId)) {

                String[] keyPickUpPointIdArray = keyPickUpPointId.split(",");
                StringBuffer buffer = new StringBuffer();
                for(String pointId : keyPickUpPointIdArray){
                    buffer.append(DataTypeUtil.quoteStr(pointId)).append(",");
                }
                String keyPickupPointIdIn = buffer.substring(0,buffer.length()-1);

                sql += " and t.pick_up_point_id in ( " + keyPickupPointIdIn + " ) ";
            }

            if (keyPickUpGoodsWayId != -1L) {
                sql += " and t.pick_up_goods_way_id = " + keyPickUpGoodsWayId;
            }

            if (keySignChooseId != -1L) {
                sql += " and t.sign_choose_id = " + keySignChooseId;
            }

            if (keyBillLoadStatusId != -1L) {
                sql += " and t.bill_load_status_id = " + keyBillLoadStatusId;
            }

            if (!"".equals(keyOpenBillStartDate)) {
                if (!"".equals(keyOpenBillEndDate)) {
                    int d = keyOpenBillStartDate.compareTo(keyOpenBillEndDate);
                    if (d > 0) {
                        String tempDate = keyOpenBillStartDate;
                        keyOpenBillStartDate = keyOpenBillEndDate;
                        keyOpenBillEndDate = tempDate;
                    }
                    sql += " and (date_format(t.create_time,'%Y-%m-%d') between " + DataTypeUtil.quoteStr(keyOpenBillStartDate) + " and " + DataTypeUtil.quoteStr(keyOpenBillEndDate) + ")";
                } else {
                    sql += " and date_format(t.create_time,'%Y-%m-%d') >= " + DataTypeUtil.quoteStr(keyOpenBillStartDate);
                }
            } else {
                if (!"".equals(keyOpenBillEndDate)) {
                    sql += " and date_format(t.create_time,'%Y-%m-%d') <= " + DataTypeUtil.quoteStr(keyOpenBillEndDate);
                }
            }

            if (keyCashierId != null) {
                sql += " and t.cashier_id = " + DataTypeUtil.quoteStr(keyCashierId);
            }

            if (keyOpenBillDepartmentId != null) {
                sql += " and t.open_bill_department_id = " + DataTypeUtil.quoteStr(keyOpenBillDepartmentId);
            }

            if (keyAgentDeliveryChargeStatusId != null) {
                sql += " and t.agent_delivery_charge_status_id = " + keyAgentDeliveryChargeStatusId;
            }


            if (keyAgentDeliveryChargeAccountCheckStatusId != null) {
                sql += " and t.agent_delivery_charge_account_check_status_id = " + keyAgentDeliveryChargeAccountCheckStatusId;
            }

            if (keyBusinessCostStatusId != null) {
                sql += " and t.business_cost_status_id = " + keyBusinessCostStatusId;
            }

            if (keySettlementStatusId != null) {
                sql += " and t.settlement_status_id = " + keySettlementStatusId;
            }

            if (keyDropStatusId != null) {
                sql += " and t.drop_status_id = " + keyDropStatusId;
            }

            if (keyAccountCheckStatusId != null) {
                sql += " and t.account_check_status_id = " + keyAccountCheckStatusId;
            }

            if (keyCancelStatusId != null) {
                sql += " and t.cancel_status_id = " + keyCancelStatusId;
            }

            if (keyDeliveryCustomerContactId != null) {
                sql += " and t.delivery_customer_contact_id = " + DataTypeUtil.quoteStr(keyDeliveryCustomerContactId);
            }

            if (keyExcludeBillCodeIds != null) {
                sql += " and t.id not in (" + keyExcludeBillCodeIds + ")";
            }

            if (keyShareCostCommentLength != null) {
                sql += " and t.share_cost_comment is not null";
            }


            //Long keyDeliveryCustomerPaymentMethodId = DataTypeUtil.toLong(map.get("keyDeliveryCustomerPaymentMethodId"),-1);
            //                Long keyReceiveCustomerPaymentMethodId = DataTypeUtil.toLong(map.get("keyReceiveCustomerPaymentMethodId"),-1);

            if (keyDeliveryCustomerPaymentMethodId != -1L) {
                sql += " and t.delivery_customer_payment_method_id = " + keyDeliveryCustomerPaymentMethodId;
            }

            if (keyReceiveCustomerPaymentMethodId != -1L) {
                sql += " and t.receive_customer_payment_method_id = " + keyReceiveCustomerPaymentMethodId;
            }

            if (createOrUpdateUserId != null) {
                sql += " and (t.create_user_id=" + DataTypeUtil.quoteStr(createOrUpdateUserId) + " or t.update_user_id=" + DataTypeUtil.quoteStr(createOrUpdateUserId) + ")";
            }
            return sql;
        }

        public String queryBillReceiveCustomerByDeliveryCustomerId(Map map) {
            String sql = new SQL() {{
                SELECT(" distinct t.receive_customer_name,t.receive_customer_phone,t.receive_customer_address");
                FROM("b_native_bill t");
                WHERE("1=1 ");
            }}.toString();

            if (map != null) {

                String queryDeliveryCustomerId = DataTypeUtil.toStringObject(map.get("queryDeliveryCustomerId"));
                String queryReceiveCustomerName = DataTypeUtil.toStringObject(map.get("queryReceiveCustomerName"));

                if (queryDeliveryCustomerId != null) {
                    sql += " and t.delivery_customer_id = " + DataTypeUtil.quoteStr(queryDeliveryCustomerId);
                }

                if (queryReceiveCustomerName != null) {
                    sql += " and (t.receive_customer_name like " + DataTypeUtil.quoteAllLikeStr(queryReceiveCustomerName) + " or t.receive_customer_phone like " + DataTypeUtil.quoteAllLikeStr(queryReceiveCustomerName) + ")";
                }
            }

            return sql;
        }

        public String queryDepartmentOpenBillCollectList(String startDate, String endDate) {
            String sql = new SQL() {{
                SELECT("xd.name openDepartmentName, sum(t.total_number-t.refund_number) totalNumber, sum(t.actual_weight-t.refund_actual_weight) totalActualWeight, sum(t.chargeable_weight-t.refund_chargeable_weight) totalChargeableWeight, sum(t.settlement_amount) totalSettlementAmount");
                FROM("b_native_bill t left join xt_department xd on t.attribution_department_id=xd.id");
                WHERE("date_format(t.create_time,'%Y-%m-%d') >= #{startDate} and date_format(t.create_time,'%Y-%m-%d') <= #{endDate} and t.attribution_department_id!='' ");
                GROUP_BY("xd.name");
            }}.toString();
            return sql;
        }

        public String queryDepartmentDailyOpenBillCollectList(String startDate, String endDate) {
            String sql = new SQL() {{
                SELECT("xd.name openDepartmentName, date_format(t.create_time,'%Y-%m-%d') openBillDate ,count(0) billNumber");
                FROM("b_native_bill t left join xt_department xd on t.attribution_department_id=xd.id");
                WHERE("date_format(t.create_time,'%Y-%m-%d') >= #{startDate} and date_format(t.create_time,'%Y-%m-%d') <= #{endDate} and t.attribution_department_id!='' ");
                GROUP_BY("xd.name,date_format(t.create_time,'%Y-%m-%d')");
                ORDER_BY("openBillDate");
            }}.toString();
            return sql;
        }


        public String totalCalc(JSONObject jsonObject){
            String sql = new SQL() {{
                SELECT("count(0) totalBillCount, sum(ifnull(t.total_number,0)) totalNumber, round(sum(ifnull(t.actual_weight,0))) totalActualWeight, round(sum(ifnull(t.chargeable_weight,0))) totalChargeableWeight, round(sum(ifnull(t.agent_delivery_charge,0))) totalAgentDeliveryCharge, round(sum(ifnull(t.service_charge,0))) totalServiceCharge, round(sum(ifnull(t.total_amount,0))) totalAmount, round(sum(ifnull(t.settlement_amount,0))) totalSettlementAmount, round(sum(ifnull(t.share_cost,0))) totalShareCost, round(sum(ifnull(t.gross_profit,0))) totalGrossProfit");
                FROM("b_native_bill t");
                WHERE("1=1 ");
            }}.toString();

            if (jsonObject != null && jsonObject.size()>0) {
                Map<String,Object> map = DataTypeUtil.jsonObjectToMap(jsonObject);
                sql = queryCndCreate(map,sql);
            }

            return sql;
        }


        public String delete(String billId) {
            String sql = new SQL() {{
                DELETE_FROM("b_native_bill t");
                WHERE("t.id = #{billId}");
            }}.toString();
            return sql;
        }

    }


    /**
     * @param id
     * @return
     */
    @Results(id = "bNativeBillPojoMapId", value = {
            @Result(column = "id", property = "id"),
            @Result(column = "attribution_department_id", property = "attributionDepartmentId"),
            @Result(column = "transport_species_id", property = "transportSpeciesId"),
            @Result(column = "transport_way_id", property = "transportWayId"),
            @Result(column = "transport_scope_id", property = "transportScopeId"),
            @Result(column = "city_id", property = "cityId"),
            @Result(column = "dest_city_id", property = "destCityId"),

            @Result(column = "delivery_customer_id", property = "deliveryCustomerId"),
            @Result(column = "delivery_customer_name", property = "deliveryCustomerName"),
            @Result(column = "delivery_customer_phone", property = "deliveryCustomerPhone"),
            @Result(column = "delivery_customer_address", property = "deliveryCustomerAddress"),

            @Result(column = "delivery_customer_contact_id", property = "deliveryCustomerContactId"),
            @Result(column = "delivery_customer_contact_name", property = "deliveryCustomerContactName"),
            @Result(column = "delivery_customer_contact_phone", property = "deliveryCustomerContactPhone"),

            @Result(column = "receive_customer_name", property = "receiveCustomerName"),
            @Result(column = "receive_customer_phone", property = "receiveCustomerPhone"),
            @Result(column = "receive_customer_address", property = "receiveCustomerAddress"),

            @Result(column = "pick_up_point_id", property = "pickUpPointId"),
            @Result(column = "pick_up_point_name", property = "pickUpPointName"),
            @Result(column = "pick_up_point_phone", property = "pickUpPointPhone"),
            @Result(column = "pick_up_point_address", property = "pickUpPointAddress"),
            @Result(column = "pick_up_goods_way_id", property = "pickUpGoodsWayId"),

            @Result(column = "sign_choose_id", property = "signChooseId"),
            @Result(column = "delivery_customer_saleman_id", property = "deliveryCustomerSalemanId"),
            @Result(column = "airport_id", property = "airportId"),
            @Result(column = "flight_date", property = "flightDate"),
            @Result(column = "flight_no", property = "flightNo"),
            @Result(column = "flight_name", property = "flightName"),
            @Result(column = "airlines_id", property = "airlinesId"),
            @Result(column = "plan_take_off_time", property = "planTakeOffTime"),
            @Result(column = "goods_name", property = "goodsName"),
            @Result(column = "goods_type_id", property = "goodsTypeId"),
            @Result(column = "packing_way_id", property = "packingWayId"),

            @Result(column = "volume_information", property = "volumeInformation"),
            @Result(column = "total_number", property = "totalNumber"),
            @Result(column = "actual_weight", property = "actualWeight"),
            @Result(column = "chargeable_weight", property = "chargeableWeight"),
            @Result(column = "weight_rate", property = "weightRate"),
            @Result(column = "volume", property = "volume"),
            @Result(column = "volume_rate", property = "volumeRate"),
            @Result(column = "ticket_price", property = "ticketPrice"),
            @Result(column = "transport_cost", property = "transportCost"),

            @Result(column = "declared_value", property = "declaredValue"),
            @Result(column = "insurance_rate", property = "insuranceRate"),
            @Result(column = "insurance_fee", property = "insuranceFee"),
            @Result(column = "open_bill_delivery_charge", property = "openBillDeliveryCharge"),
            @Result(column = "agent_delivery_charge", property = "agentDeliveryCharge"),
            @Result(column = "delivery_charge_comment", property = "deliveryChargeComment"),

            @Result(column = "agent_delivery_charge_account_check_status_id", property = "agentDeliveryChargeAccountCheckStatusId"),

            @Result(column = "pickup_driver_fee", property = "pickupDriverFee"),
            @Result(column = "pickup_driver_name", property = "pickupDriverName"),


            @Result(column = "tax", property = "tax"),
            @Result(column = "fuel_surcharge", property = "fuelSurcharge"),
            @Result(column = "collection_money", property = "collectionMoney"),
            @Result(column = "other_charges", property = "otherCharges"),
            @Result(column = "other_charges_comment", property = "otherChargesComment"),
            @Result(column = "service_charge", property = "serviceCharge"),
            @Result(column = "actual_transport_cost", property = "actualTransportCost"),

            @Result(column = "business_cost_allocation_id", property = "businessCostAllocationId"),
            @Result(column = "business_cost_allocation_type_id", property = "businessCostAllocationTypeId"),
            @Result(column = "business_cost_comment", property = "businessCostComment"),

            @Result(column = "print_actual_weight", property = "printActualWeight"),
            @Result(column = "print_chargeable_weight", property = "printChargeableWeight"),
            @Result(column = "print_weight_rate", property = "printWeightRate"),
            @Result(column = "print_volume", property = "printVolume"),
            @Result(column = "print_volume_rate", property = "printVolumeRate"),

            @Result(column = "inner_operation_charge", property = "innerOperationCharge"),
            @Result(column = "delivery_customer_payment_method_id", property = "deliveryCustomerPaymentMethodId"),
            @Result(column = "delivery_customer_payment_amount", property = "deliveryCustomerPaymentAmount"),
            @Result(column = "receive_customer_payment_method_id", property = "receiveCustomerPaymentMethodId"),
            @Result(column = "receive_customer_payment_amount", property = "receiveCustomerPaymentAmount"),

            @Result(column = "total_amount", property = "totalAmount"),
            @Result(column = "actual_amount", property = "actualAmount"),
            @Result(column = "cashier_id", property = "cashierId"),
            @Result(column = "open_bill_user_id", property = "openBillUserId"),
            @Result(column = "open_bill_date", property = "openBillDate"),
            @Result(column = "open_bill_department_id", property = "openBillDepartmentId"),
            @Result(column = "roll_call_department_id", property = "rollCallDepartmentId"),
            @Result(column = "comment", property = "comment"),

            @Result(column = "bill_load_status_id", property = "billLoadStatusId"),
            @Result(column = "bill_load_master_bill_ids", property = "billLoadMasterBillIds"),
            @Result(column = "business_cost_status_id", property = "businessCostStatusId"),
            @Result(column = "agent_delivery_charge_status_id", property = "agentDeliveryChargeStatusId"),
            @Result(column = "arrears_status_id", property = "arrearsStatusId"),
            @Result(column = "share_cost", property = "shareCost"),
            @Result(column = "share_cost_comment", property = "shareCostComment"),
            @Result(column = "operating_cost", property = "operatingCost"),
            @Result(column = "gross_profit", property = "grossProfit"),

            @Result(column = "drop_amount", property = "dropAmount"),
            @Result(column = "settlement_amount", property = "settlementAmount"),
            @Result(column = "drop_status_id", property = "dropStatusId"),
            @Result(column = "settlement_status_id", property = "settlementStatusId"),

            @Result(column = "cancel_status_id", property = "cancelStatusId"),
            @Result(column = "account_check_status_id", property = "accountCheckStatusId"),

            @Result(column = "refund_number", property = "refundNumber"),
            @Result(column = "refund_actual_weight", property = "refundActualWeight"),
            @Result(column = "refund_chargeable_weight", property = "refundChargeableWeight"),
            @Result(column = "refund_volume", property = "refundVolume"),


            @Result(column = "create_time", property = "createTime"),
            @Result(column = "create_user_id", property = "createUserId"),
            @Result(column = "update_time", property = "updateTime"),
            @Result(column = "update_user_id", property = "updateUserId")
    })
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "getBNativeBillPojoById")
    BNativeBillPojo getBNativeBillPojoById(String id);

    @ResultMap("bNativeBillPojoMapId")
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "getBNativeBillPojoListByInId")
    List<BNativeBillPojo> getBNativeBillPojoListByInId(String billIds);

    @ResultMap("bNativeBillPojoMapId")
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "getBNativeBillPojoByCnd")
    List<BNativeBillPojo> getBNativeBillPojoByCnd(Map param);

    @ResultMap("bNativeBillPojoMapId")
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "queryBNativeBillPojoListByMasterBillId")
    List<BNativeBillPojo> queryBNativeBillPojoListByMasterBillId(String masterBillId);

    @ResultType(Map.class)
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "queryBillReceiveCustomerByDeliveryCustomerId")
    List<Map<String, Object>> queryBillReceiveCustomerByDeliveryCustomerId(Map<String, Object> param);

    @ResultType(Map.class)
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "queryDepartmentOpenBillCollectList")
    List<Map<String, Object>> queryDepartmentOpenBillCollectList(String startDate, String endDate);

    @ResultType(Map.class)
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "queryDepartmentDailyOpenBillCollectList")
    List<Map<String, Object>> queryDepartmentDailyOpenBillCollectList(String startDate, String endDate);


    @ResultMap("bNativeBillPojoMapId")
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "findAll")
    List findAll(Map param);


    @ResultType(Map.class)
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "totalCalc")
    Map<String, Object> totalCalc(JSONObject param);


    @ResultMap("bNativeBillPojoMapId")
    @SelectProvider(type = BNativeBillMapperProvider.class, method = "getDailyReportList")
    List<BNativeBillPojo> getDailyReportList(Map<String, Object> param);

    @InsertProvider(type = BNativeBillMapperProvider.class, method = "insert")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(BNativeBillPojo pojo);

    @UpdateProvider(type = BNativeBillMapperProvider.class, method = "update")
    int update(BNativeBillPojo pojo);

    @UpdateProvider(type = BNativeBillMapperProvider.class, method = "updateSaveNativeBill")
    int updateSaveNativeBill(BNativeBillPojo pojo);

    @UpdateProvider(type = BNativeBillMapperProvider.class, method = "updateLoadStatus")
    int updateLoadStatus(String billId, long loadStatusId);

    @UpdateProvider(type = BNativeBillMapperProvider.class, method = "updateStatusId")
    int updateStatusId(String statusFieldName, Long statusId, String billIds, Date updateTime, String updateUserId);

    @DeleteProvider(type = BNativeBillMapperProvider.class, method = "delete")
    int delete(String billId);

}
